package com.tc.groovy


/**
 * Created by cai.tian on 2018/1/17.
 */
class ConfigDelegate {
    void appender(String name, String age,Class clazz ,Closure closure = null) {
        def instance = clazz.newInstance();
        instance.name = name;
        instance.age = age;
        if(closure!=null){
            ComponentDelegate dg=new ComponentDelegate(instance);
            closure.delegate = dg;
            closure.resolveStrategy = Closure.DELEGATE_FIRST
            def a = closure();
            println(instance.getName())
            instance.speak.say("abc")
        }
    }


}
